/*
 * @Author: your name
 * @Date: 2021-07-08 15:57:00
 * @LastEditTime: 2021-07-22 14:09:12
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \cuiyuan_activity\assets\script\Controller.ts
 */
// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

const { ccclass, property } = cc._decorator;

@ccclass
export default class Controller extends cc.Component {

    static inst: Controller;

    @property(cc.SpriteFrame)
    play: cc.SpriteFrame = null;

    @property(cc.SpriteFrame)
    pause: cc.SpriteFrame = null;

    // LIFE-CYCLE CALLBACKS:

    onLoad() {
        Controller.inst = this;
    }

    /**
     * @description 修改小红旗的背景
     * @param status play | pause
     */
    init(status: string) {
        this.node.getComponent(cc.Sprite).spriteFrame = this[status];
    }

    hide() {
        this.node.opacity = 255;
        // 添加一个动画
        cc.tween(this.node).to(0.5, { opacity: 0 }).call(() => {
            this.node.active = false;
        }).start()
    }
    show() {
        this.node.opacity = 0;
        this.node.active = true;
        // 添加一个动画
        cc.tween(this.node).to(0.5, { opacity: 255 }).start()
    }

    start() {

    }

    // update (dt) {}
}
